import { ListNode } from "./ListNode"

/**
 * 141. 环形链表
 * @param head 头节点
 * @returns Boolean
 */
function hasCycle(head: ListNode | null): boolean {
  let slow = head
  let fast = head
  while (slow && fast && fast.next) {
    slow = slow.next
    fast = fast.next.next
    if (slow === fast) {
      return true
    }
  }
  return false
}